package com.example.hotelsystem.controller.profit;

import code.CodeError;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.hotelsystem.entity.Profit;
import com.example.hotelsystem.entity.Room;
import com.example.hotelsystem.result.Result;
import com.example.hotelsystem.service.ProfitService;
import com.example.hotelsystem.vo.profit.ProfitSearchVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hotelsystem/profit")
@Api(tags = "统计每日利息控制器控制器")
public class ProfitController {

    @Autowired
    ProfitService profitService;

    @PostMapping("/list")
    @ApiOperation("生成订单接口")
    public Result ProfitList(ProfitSearchVO profitSearchVO){
        QueryWrapper<Profit> query = new QueryWrapper<>();
        if(profitSearchVO.getStartTime()!=null&&profitSearchVO.getEndTime()!=null){
            query.ge("day",profitSearchVO.getStartTime());
            query.le("day",profitSearchVO.getEndTime());
        }
        List<Profit> list = profitService.list(query);
        if(list!=null){
            return Result.success("盈利结果查询成功",list);
        }
        return Result.error(CodeError.PROFIT_LIST_NULL,"盈利查询结果为空");
    }
}
